let ratings = [1,2,87,87,87,2,1]
var distributeCandy = (ratings) => {
    ratings.sort((a, b) => a - b)
    console.log('distributeCandy->ratings:', ratings)
    
    let n = ratings.length
    let i = 0
    let count = 0
    while(i < n){
        if(ratings[i] < ratings[i + 1]){
            count++
        }
        count++
        i++
    }
    console.log('distributeCandy->count:', count)

    return count
};

distributeCandy(ratings)